#pragma once

#include <cstdint>
#include <vector>
#include <string>

#include "protocol_analyzer.hh"
#include "../corelib/network/network.hh"

namespace kratos { namespace engine {

// ProtocolAnalyzer implementation
class ProtocolAnalyzerImpl : public ProtocolAnalyzer {
public:
    // ctor
    ProtocolAnalyzerImpl();
    // dtor
    virtual ~ProtocolAnalyzerImpl();
    virtual bool setAnalyzer(const std::string& analyzer);

public:
    // check is there complete packet in reader's buffer
    // @param reader session's buffer reader
    // @param size packet size in bytes
    // @retval true
    // @retval false
    bool hasFullPacket(network::SessionReader& reader, std::size_t& size);
    // Is parsed?
    bool isParsed();

private:
    std::size_t headerSize_; // header size of packet
    bool includeHeader_; // Is packet length include header size?
    std::size_t lenghPos_; // the begin of length section in header in bytes
    std::size_t lengthBytes_; // how many bytes of length section?
    bool parsed_; // parsed
};

}}
